<template>
	<wd-swiper
		class="swiper"
		:list="imageList"
		style="padding: 12rpx"
		:autoplay="false"
		:current="0"
		@click="handleClick"
	></wd-swiper>
</template>
<script setup>
import { http } from '@/utils/http'

const swiperList = ref([])

const imageList = computed(() => swiperList.value.map((item) => item.image))

const getData = async () => {
	let res = await http({
		url: '/api/home/banners',
		data: {
			pageNum: 1,
			pageSize: 10,
		},
	})

	if (res.code == 200) {
		swiperList.value = res.data.banners
	}
}

onLoad(() => {
	getData()
})

function handleClick({ index }) {
	if (swiperList.value[index].path) {
		uni.navigateTo({ url: swiperList.value[index].path })
	}
}
</script>
<style lang="scss" scoped>
.swiper {
	width: 710rpx;
}
</style>
